import { Order } from "../../../util/request/api"
const state = {
  itemList: [],
  orderList: [],
  chosenAddr: 0,
  cost: {}
}
const getters = {
  getItemList(state) {
    return state.itemList
  },
  getOrderList(state) {
    return state.orderList
  },
  getChosenAddr(state) {
    return state.chosenAddr
  },
  getCost(state) {
    return state.cost
  }
}
const mutations = {
  CHANGE_ITEMLIST(state, newList) {
    state.itemList = newList
  },
  CHANGE_ORDER(state, newList) {
    state.orderList = newList
  },
  CHANGE_ADDR(state, newobj) {
    state.chosenAddr = newobj
  },
  CHANGE_COST(state, newnum) {
    state.cost = newnum
  }
}
const actions = {
  changeAction({ commit }, payload) {
    commit("CHANGE_ITEMLIST", payload)
  },
  changeOrderAction({ commit }, payload) {
    commit("CHANGE_ORDER", payload)
  },
  changeAddrAction({ commit }, payload) {
    commit("CHANGE_ADDR", payload)
  },
  changeCostAction({ commit }, payload) {
    commit("CHANGE_COST", payload)
  }
}

export default {
  state,
  getters,
  mutations,
  actions,
}